function calcZoom(
  nmap: Record<string, 1> = {},
  zoom: Record<string, number> = {},
) {
  const nmapKeys = Object.keys(nmap)
    .map((k) => Number(k.slice(1)))
    .sort((a, b) => a - b);
  const minNmap = nmapKeys.length > 0 ? nmapKeys[0] : 24;
  const maxNmap = nmapKeys.length > 0 ? nmapKeys[nmapKeys.length - 1] : 0;

  const zoomEntries = Object.entries(zoom)
    .map((z) => {
      const zoomKey = Number(z[0].slice(1)); // 去掉前缀 'z'
      return [zoomKey, z[1]];
    })
    .sort((a, b) => a[0] - b[0]);
  const fmtZoom: Record<string, number> = {};
  const tempMinZoom = zoomEntries.find((ze) => ze[1] !== 0); //  第一个不为 0 的 zoom值
  const minZoom = tempMinZoom
    ? tempMinZoom[0]
    : zoomEntries.length
      ? zoomEntries[zoomEntries.length - 1][0] + 1
      : 25;
  for (let i = minZoom; i <= 24; i++) {
    if (zoom[`z${i}`] !== undefined) {
      fmtZoom[`z${i}`] = zoom[`z${i}`];
    } else {
      fmtZoom[`z${i}`] = fmtZoom[`z${i - 1}`] || 1; // 如果没有配置，使用默认值
    }
  }

  return {
    minN: minNmap,
    maxN: maxNmap,
    ...fmtZoom,
    minZ: minZoom,
  };
}

console.log(calcZoom({}, { z20: 0 }));
